public class gcd {
	public static void main(String[] args) {
		int m = 1000, n = 495, num;
		num = m < n ? m : n;
		while(0 != m % num || 0 != n % num || num>1 ) {
			num=num-1;
		}
		System.out.printf("The gcd of %d and %d is %d%n", m, n, num);
	}
}
